<?
if ($this->character->stats['spellincrease'] > 0)
{
?>
<div class="banner">
  <h3>Learn New Magic Spells:</h3>
  You can acquire <b><?= $this->character->stats['spellincrease'] ?> new 
    <?= makePlural('spell', $this->character->stats['spellincrease']) ?></b> from this list:
  <table>
  <?
  foreach(DB_GetList('SELECT * FROM '.getTableName('spells').'
    LEFT JOIN '.getTableName('character_spells').' ON (cs_character="'.$this->character->charDS['c_key'].'" AND cs_spell=sp_key)
    WHERE sp_level <= '.$this->character->level.' AND cs_key IS NULL
    ORDER BY sp_level,sp_name') as $spellDS)
  {
  ?><tr>
    <td valign="top" style="padding-top: 4px"><a
      href="<?= actionUrl('index', 'character', 'buyspell='.$spellDS['sp_key']) ?>" 
      class="linkbutton">learn</a></td>
    <td valign="top">
      <b><?= $spellDS['sp_name'] ?></b> (power level <?= $spellDS['sp_level'] ?>)<br/>
      <?= $spellDS['sp_info'] ?>
    </td>
  </tr><?
  }
  ?>
  </table>
</div><br/>
<?
}

if (sizeof($this->mySpells) > 0)
{
  $row = 0;
  ?><h3>My Spells</h3><table width="100%" cellspacing="0" cellpadding="4"><?
  foreach($this->mySpells as $spell)
  {
    $row++;
    ?><tr <? if ($row % 2 != 0) print('class="tr_odd"'); ?> <?= toolTip(':'.htmlentities($spell['sp_info']).' - costs '.$spell['sp_level'].' MP / '.floor($spell['sp_level']/2).' AP to use') ?>>
      <td valign="top"><b><?= $spell['sp_name'] ?></b></td>
      <td><?= $spell['sp_level'] ?></td>
      <td valign="top" width="5%"><div align="center"><?
      if ($spell['sp_type'] == 'buff')
      {
      ?><a href="<?= actionUrl('index', 'character', 'cast='.$spell['sp_key']) ?>" class="linkbutton">cast!</a><?
      }
      else
        print('<span style="color: gray">combat</span>');
      ?></div></td>
    </tr><?
  }
  $row = 0;
  ?></table><?
}
?>